/*
ID: cherish2
LANG: JAVA
PROG: ride
*/
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

class ride {

	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new FileReader("ride.in"));
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(
				"ride.out")));
		StringBuffer buffer = new StringBuffer();
		String text;
		while((text = reader.readLine()) != null){
			buffer.append(text + ',');
		}
		text = buffer.toString();
		StringTokenizer st = new StringTokenizer(text, ",");
		
		Map map = new HashMap();
		char[] letter = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
				'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
		for(int i = 0; i < letter.length; i++){
			map.put(letter[i], i + 1);
		}		
		List<Integer> list = new ArrayList<Integer>();
		while(st.hasMoreTokens()){
			String txt = st.nextToken();
			int b = 1;
			for(int i = 0; i < txt.length(); i++){
				b *= (Integer)(map.get(txt.charAt(i)));				
			}
			list.add(b);
		}
 
	    int I1 = list.get(0);
	    int I2 = list.get(1);
	   
	    if(I1 % 47 == I2 % 47){
	    	out.println("GO");
	    }else{
	    	out.println("STAY");
	    }
	    
		out.close();
		System.exit(0);

	}

}
